const XLSX = require("xlsx");

export function exportToExcel(jsonData, filename) {
    if(!jsonData){
        throw new Error("must require json data")
    }
    // 调用导出函数
    let worksheet = XLSX.utils.json_to_sheet(jsonData);
    let workbook = XLSX.utils.book_new();
    XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
    XLSX.writeFile(workbook, `${filename}.xlsx`);
}
